home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / portfoli / bootst11.lzh / PF BOOTSTRAP VATIPX PCUC < prev    next >
Text File  |  1989-05-13  |  3KB  |  118 lines

  1. /*
  2.  * Copyright (c) 1983 The Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Berkeley.  The name of the
  11.  * University may not be used to endorse or promote products derived
  12.  * from this software without specific prior written permission.
  13.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  14.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  15.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  16.  */
  17.  
  18. #ifndef lint
  19. static char sccsid[] = "@(#)cu.c    5.7 (Berkeley) 9/2/88";
  20. #endif /* not lint */
  21.  
  22. #include "tip.h"
  23.  
  24. int    cleanup();
  25. int    timeout();
  26.  
  27. /*
  28.  * Botch the interface to look like cu's
  29.  */
  30. cumain(argc, argv)
  31.     char *argv[];
  32. {
  33.     register int i;
  34.     static char sbuf[12];
  35.  
  36.     if (argc < 2) {
  37.         printf("usage: cu telno [-t] [-s speed] [-a acu] [-l line] [-#]\n");
  38.         exit(8);
  39.     }
  40.     CU = DV = NOSTR;
  41.     BR = DEFBR;
  42.     for (; argc > 1; argv++, argc--) {
  43.         if (argv[1][0] != '-')
  44.             PN = argv[1];
  45.         else switch (argv[1][1]) {
  46.  
  47.         case 't':
  48.             HW = 1, DU = -1;
  49.             --argc;
  50.             continue;
  51.  
  52.         case 'a':
  53.             CU = argv[2]; ++argv; --argc;
  54.             break;
  55.  
  56.         case 's':
  57.             if (argc < 3 || speed(atoi(argv[2])) == 0) {
  58.                 fprintf(stderr, "cu: unsupported speed %s\n",
  59.                     argv[2]);
  60.                 exit(3);
  61.             }
  62.             BR = atoi(argv[2]); ++argv; --argc;
  63.             break;
  64.  
  65.         case 'l':
  66.             DV = argv[2]; ++argv; --argc;
  67.             break;
  68.  
  69.         case '0': case '1': case '2': case '3': case '4':
  70.         case '5': case '6': case '7': case '8': case '9':
  71.             if (CU)
  72.                 CU[strlen(CU)-1] = argv[1][1];
  73.             if (DV)
  74.                 DV[strlen(DV)-1] = argv[1][1];
  75.             break;
  76.  
  77.         default:
  78.             printf("Bad flag %s", argv[1]);
  79.             break;
  80.         }
  81.     }
  82.     signal(SIGINT, cleanup);
  83.     signal(SIGQUIT, cleanup);
  84.     signal(SIGHUP, cleanup);
  85.     signal(SIGTERM, cleanup);
  86.  
  87.     /*
  88.      * The "cu" host name is used to define the
  89.      * attributes of the generic dialer.
  90.      */
  91.     (void)sprintf(sbuf, "cu%d", BR);
  92.     if ((i = hunt(sbuf)) == 0) {
  93.         printf("all ports busy\n");
  94.         exit(3);
  95.     }
  96.     if (i == -1) {
  97.         printf("link down\n");
  98.         (void)uu_unlock(uucplock);
  99.         exit(3);
  100.     }
  101.     setbuf(stdout, NULL);
  102.     loginit();
  103.     user_uid();
  104.     vinit();
  105.     setparity("none");
  106.     boolean(value(VERBOSE)) = 0;
  107.     if (HW)
  108.         ttysetup(speed(BR));
  109.     if (lconnect()) {
  110.         printf("Connect failed\n");
  111.         daemon_uid();
  112.         (void)uu_unlock(uucplock);
  113.         exit(1);
  114.     }
  115.     if (!HW)
  116.         ttysetup(speed(BR));
  117. }
  118.